<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>springboot+freemarker表单验证</title>
</head>
<body>
<#-- 引入spring基于freemarker的标签文件    !!!! 划重点 !!!! -->
<#import "/spring.ftl" as spring />
<form action="/" method="post">
    <table>
        <tr>
            <@spring.bind "user.username" />
            <td><lable for="username">username</lable></td>
            <td><input type="text" id="username" name="username" value="${user.username!}"></td>
            <td><span style="color: red;"><@spring.showErrors ""/></span></td>
        </tr>
        <tr>
            <@spring.bind "user.sex" />
            <td><lable for="sex">sex</lable></td>
            <td><input type="text" id="sex" name="sex" value="${user.sex!}"></td>
            <td><span style="color: red;"><@spring.showErrors ""/></span></td>
        </tr>
        <tr>
            <@spring.bind "user.age" />
            <td><lable for="age">age</lable></td>
            <td><input type="text" id="age" name="age" value="${user.age!}"></td>
            <td><span style="color: red;"><@spring.showErrors ""/></span></td>
        </tr>
        <tr>
            <td colspan="3"><input type="submit" value="submit"></td>
        </tr>
    </table>
</form>
</body>
</html>